package com.techsen.tsweb.sys.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.techsen.tsweb.core.service.impl.BaseService;
import com.techsen.tsweb.core.util.ValidUtil;
import com.techsen.tsweb.sys.dao.CompanyDao;
import com.techsen.tsweb.sys.dao.OrgDao;
import com.techsen.tsweb.sys.domain.Company;
import com.techsen.tsweb.sys.domain.Org;
import com.techsen.tsweb.sys.service.CompanyService;

@Service
public class CompanyServiceImpl extends BaseService<Company, CompanyDao> implements CompanyService {

    @Resource
    private OrgDao orgDao;
    
    @Resource @Override
    public void setDao(CompanyDao dao) {
        this.dao = dao;
    }

    /**
     * 修改公司信息<br/>
     * 修改公司时，同时修改对应的组织对象
     */
    @Override
    public void update(Company company) {
        if (company != null) {
            super.update(company);
            if (ValidUtil.isValid(company.getOrgId())) {
                Org org = company.clone().setId(company.getOrgId());
                this.orgDao.update(org);
            }
        }
    }
    
}
